package org.example.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class myaop {
    @Pointcut("execution(* org.example.servlet.*.UserServlet*.add())")
    public void a(){}
    @Pointcut("execution(* org.example.*.User*.data(*))")
    public void a1(){}

    @Pointcut("execution(* org.example.servlet.UserServlet.text())")
    public void a3(){}
//前置通知
    @Before("a()")
//    后置通知
    @After("a()")
    public void ab(){
        System.out.println(123);
    }
    @Before("a1()")
    public void ab1(){
        System.out.println(123);
    }

    @Around("a3()")
    public Object ab2(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println(123);
        Object proceed = proceedingJoinPoint.proceed();
        System.out.println(456);
        return 200;
    }
}
